package Game;
import Conf.Consts;
import Exceptions.GameCenterException;
import Exceptions.GameCenterException.GameCenterExceptionType;


public class GameInfo implements IGameInfo {
	
	private String Name;
	private int EngineID;
	private int CurrentNumOfPlayers;
	private int MaxAllowedNumberOfPlayers;
	private int NumOfAiPlayers;
	
	public GameInfo(String _Name,
					int _MaxAllowedNumberOfPlayers,
					int _NumOfAiPlayers,
					int _EngineID) throws GameCenterException{
		Name=_Name;
		if (_MaxAllowedNumberOfPlayers<Consts.MinNumberOfPlayers  && _MaxAllowedNumberOfPlayers>Consts.MaxNumberOfPlayers){
			throw new GameCenterException(GameCenterExceptionType.InvalidNumberOfPlayers);
		}
		else
			MaxAllowedNumberOfPlayers=_MaxAllowedNumberOfPlayers;
		if (_NumOfAiPlayers>3 || _NumOfAiPlayers<0)
			throw new GameCenterException(GameCenterExceptionType.InvalidNumberOfAIs);
		else
			NumOfAiPlayers=_NumOfAiPlayers;
		EngineID = _EngineID;
		CurrentNumOfPlayers = NumOfAiPlayers ;
	}
	
	public int AddPlayer(String PlayerName) throws GameCenterException {
		if (CurrentNumOfPlayers<MaxAllowedNumberOfPlayers){
			CurrentNumOfPlayers++;
			return CurrentNumOfPlayers;
		}
		else 
			throw new GameCenterException(GameCenterExceptionType.GameFull);		
	}
	
	public int getMaxAllowedNumberOfPlayers(){
		return MaxAllowedNumberOfPlayers;
	}
	
	public int getCurrentNumOfPlayers(){
		return CurrentNumOfPlayers;
	}
	
	public int getEngineID(){
		return EngineID;
	}
	
	public String getName(){
		return Name;
	}
}
